package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TestOrderMapper;
import com.ruoyi.system.domain.TestOrder;
import com.ruoyi.system.service.ITestOrderService;

/**
 * 订单信息(shardingSphere分表测试)Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-03-14
 */
@Service
public class TestOrderServiceImpl implements ITestOrderService 
{
    @Autowired
    private TestOrderMapper testOrderMapper;

    /**
     * 查询订单信息(shardingSphere分表测试)
     * 
     * @param id 订单信息(shardingSphere分表测试)主键
     * @return 订单信息(shardingSphere分表测试)
     */
    @Override
    @DataSource(DataSourceType.SHARDING)
    public TestOrder selectTestOrderById(Long id, String beginTime, String endTime)
    {
        return testOrderMapper.selectTestOrderById(id, beginTime, endTime);
    }

    /**
     * 查询订单信息(shardingSphere分表测试)列表
     * 
     * @param testOrder 订单信息(shardingSphere分表测试)
     * @return 订单信息(shardingSphere分表测试)
     */
    @Override
    @DataSource(DataSourceType.SHARDING)
    public List<TestOrder> selectTestOrderList(TestOrder testOrder)
    {
        return testOrderMapper.selectTestOrderList(testOrder);
    }

    /**
     * 新增订单信息(shardingSphere分表测试)
     * 
     * @param testOrder 订单信息(shardingSphere分表测试)
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SHARDING)
    public int insertTestOrder(TestOrder testOrder)
    {
        testOrder.setCreateBy(SecurityUtils.getUsername());
        testOrder.setCreateTime(DateUtils.getNowDate());
        return testOrderMapper.insertTestOrder(testOrder);
    }

    /**
     * 修改订单信息(shardingSphere分表测试)
     * 
     * @param testOrder 订单信息(shardingSphere分表测试)
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SHARDING)
    public int updateTestOrder(TestOrder testOrder)
    {
        testOrder.setUpdateBy(SecurityUtils.getUsername());
        testOrder.setUpdateTime(DateUtils.getNowDate());
        return testOrderMapper.updateTestOrder(testOrder);
    }

    /**
     * 批量删除订单信息(shardingSphere分表测试)
     * 
     * @param ids 需要删除的订单信息(shardingSphere分表测试)主键
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SHARDING)
    public int deleteTestOrderByIds(Long[] ids, String beginTime, String endTime)
    {
        return testOrderMapper.deleteTestOrderByIds(ids, beginTime, endTime);
    }

    /**
     * 删除订单信息(shardingSphere分表测试)信息
     * 
     * @param id 订单信息(shardingSphere分表测试)主键
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SHARDING)
    public int deleteTestOrderById(Long id, String beginTime, String endTime)
    {
        return testOrderMapper.deleteTestOrderById(id, beginTime, endTime);
    }
}
